export function formatterDate(d,type){
    let date = new Date();
    if(d){
        date = new Date(d);
    }

    let year = date.getFullYear();
    let month = date.getMonth()+1;
    let day = date.getDate();
    month = month<10?`0${month}`:month;
    day = day<10?`0${day}`:day;

    let h = date.getHours();
    h = h<10?`0${h}`:h;
    let m = date.getMinutes();
    m = m<10?`0${m}`:m;
    let s = date.getSeconds();
    s = s<10?`0${s}`:s;

    let week = `星期${"日一二三四五六".split(/(?!\b)/)[date.getDay()]}`;
    type = type || "yy-mm-dd";
    type = type.toLocaleLowerCase();
    let str = `${year}-${month}-${day}`
    if(type=="yy-mm-dd hh:mm:ss"){
        str = `${year}-${month}-${day} ${h}:${m}:${s}`
    }else if(type=="yy-mm-dd hh:mm:ss w"){
        str = `${year}-${month}-${day} ${h}:${m}:${s} ${week}`
    }

    return str
}


//生成字符串
export function uuid() {
    return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16));
}